<template>
  <AMISRenderer :schema="schema" />
</template>

<script setup>
import AMISRenderer from '@/components/AMISRenderer.vue'

const schema = {
  type: 'page',
  body: {
    type: 'crud',
    api: '/base/auth/online/user/list',
    syncLocation: false,
    autoFillHeight: true,
    name:'online-user-list',
    footerToolbar: [
      'statistics',
      'switch-per-page',
      'pagination'
    ],
    headerToolbar: [
      {
        label: '刷新',
        icon: 'fa fa-repeat',
        type: 'button',
        actionType: 'ajax',
        api: 'post:/base/auth/online/user/refresh',
        reload: 'online-user-list',
        align: 'right'
      }
    ],
    autoGenerateFilter: {
      showBtnToolbar: false,
      columnsNum: 3
    },
    columns: [
      {
        name: 'userId',
        label: '用户Id',
        //默认不展示
        toggled: false,
      },
      {
          name: 'username',
          label: '用户名'
      },
      {
        name: 'orgId',
        label: '机构Id',
        //默认不展示
        toggled: false,
      },
      {
          name: 'orgName',
          label: '机构名称'
      },
      {
        name: 'loginDate',
        label: '登录时间'
      },
      {
          name: 'loginUrl',
          label: 'url'
      },
      {
          name: 'ipRegion',
          label: 'ip地区'
      },
      {
          name: 'token',
          label: 'token'
      },
      {
        type: 'operation',
        label: '操作',
        buttons: [
          {
            label: '下线',
            type: 'button',
            level: 'danger',
            actionType:'ajax',
            confirmText: '确认要下线当前账号？',
            api: '/base/auth/kick?authorization=${token}',
          }
        ]
      }
    ], 
  },
}

</script>
